package com.kingre.et.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 维度
 * 
 * @author Jingui.Yu
 * 
 */
@Entity
@Table(name = "t_dimensionality")
public class Dimensionality extends BaseObject implements Serializable {
    private static final long serialVersionUID = -8536358031894611157L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false, length = 256)
    private String name;

    @Column(nullable = false, length = 512)
    private String alias;

    @Column(nullable = false, length = 512)
    private String description;

    @Column(name = "mean_score")
    private Float meanScore;

    @Column(name = "sd")
    private Float sd;

    @OneToMany(mappedBy = "dimension", targetEntity = Questionnaire.class)
    private Set<Questionnaire> question;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Float getMeanScore() {
        return meanScore;
    }

    public void setMeanScore(Float meanScore) {
        this.meanScore = meanScore;
    }

    public Float getSd() {
        return sd;
    }

    public void setSd(Float sd) {
        this.sd = sd;
    }

    public Set<Questionnaire> getQuestion() {
        return question;
    }

    public void setQuestion(Set<Questionnaire> question) {
        this.question = question;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append("id", id).append("name", name).toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Dimensionality)) {
            return false;
        }
        final Dimensionality dimensionality = (Dimensionality) o;
        return this.hashCode() == dimensionality.hashCode();
    }

    @Override
    public int hashCode() {
        int result;
        result = (id != null ? id.hashCode() : 0);
        result = 29 * result + (name != null ? name.hashCode() : 0)
                + (description != null ? description.hashCode() : 0) + (meanScore != null ? meanScore.hashCode() : 0)
                + (sd != null ? sd.hashCode() : 0);
        return result;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

}
